﻿using Microsoft.Practices.Unity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FileSystem
{
    public class FileSystemServiceLocator :IServiceLocator 
    {
        #region Private Fields

        private UnityContainer container;

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="QAdminServiceLocator"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        public FileSystemServiceLocator(UnityContainer container)
        {
            this.container = container;
        }

        #endregion

        #region IServiceLocator Implementation

        /// <summary>
        /// Resolves this instance.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public T Resolve<T>()
        {
            return container.Resolve<T>();
        }

        /// <summary>
        /// Resolves the specified name.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public T Resolve<T>(string name)
        {
            return container.Resolve<T>(name);
        }

        /// <summary>
        /// Resolves the specified name.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name">The name.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns></returns>
        public T Resolve<T>(string name, object[] parameters)
        {
            return container.Resolve<T>(name, new OrderedParametersOverride(parameters));
        }

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public IEnumerable<T> ResolveAll<T>()
        {
            return container.ResolveAll<T>();
        }


    #endregion
    }
}
